#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

int main() {
  string filename; //holds name of file to be read
  string lines; //holds contents of file by line
  string buffer;
  stringstream ss(lines);
  vector < vector <double> > tokens;

  cout << "Which file would you like to read? \n" << endl;
  cin >> filename;
  cout << "You chose " << filename << endl;

  ifstream myfile;
  myfile.open(filename.c_str());
  if (myfile.is_open()) {
    cout << "opened via ifstream" << endl;
    while(myfile.good()) {
      getline(myfile,lines);
      while (ss >> buffer) {
	tokens.push_back(buffer);
      }
      cout << lines << endl;
      for (vector<string>::iterator i = tokens.begin(); i != tokens.end(); ++i) {
	cout << *i << endl;
	}
    }
  }
  myfile.close();
 
  return 0;

}
